package cn.edu.zafu.bigdata.zqt.findMax;

import java.util.List;

public class Main {

    public static void main(String[] args) {
        List<Integer> list1 = List.of(1, 2, 3, 4, 5);
        List<String> list2 = List.of("a", "b", "c");

        Integer MaxInt = findMax(list1);
        String MaxStr = findMax(list2);

        System.out.println("Max Int: " + MaxInt);
        System.out.println("Max Str: " + MaxStr);
    }

    public static <T extends Comparable<T>> T findMax(List<T> list) {
        if (list.isEmpty()) {
            return null;
        }
        T max = list.get(0);

        for (T t : list) {
            if (t.compareTo(max) > 0) {
                max = t;
            }
        }
        return max;
    }
}
